<?php

/**
 * @author kevin
 * @date 2016-01-16 14:00:00
 * @desc 品牌管理
 */

if (!defined('IN_ECS'))
{
    die('Hacking attempt');
}
$version = '1.0';   //版本号

if ($_POST['api_version'] != $version)      //网店的接口版本低
{
	api_err('0x008', 'a low version api');
}
if(empty($_POST['st'])){
	api_err('0x008', 'param st is Missing');
}
//热门品牌列表
if($_POST['st'] == 'hotbrand'){
	$data = get_hot_brands_list(7,1);
}
//品牌列表
if($_POST['st'] == 'list'){
	$page = abs(intval($_POST['page']));
	$page = empty($page)?1:$page;
	$size = abs(intval($_POST['size']));
	$size = ($size > 0 && $size < SIZE_MAX)?$size:SIZE_VALUE;
	$count = $GLOBALS['db']->getOne('SELECT COUNT(*) FROM ' .$GLOBALS['ecs']->table('brand').
           " ORDER BY sort_order desc");
	$pager = get_pager('user.php', array('act' => 'collection_list'), $count, $page, $size);
	$data['list'] = get_brands_list($size,$page);
	$data['page'] = get_app_pager($pager);
}
//st参数错误
if(!isset($data)){
	api_err('0x008');
}
//返回数据
data_back($data, '', RETURN_TYPE);
